import com.google.gson.Gson;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import static java.lang.Thread.sleep;

/**
 * @author zhangrui
 * @date 2020-04-04 19:08
 */
public class EveryProject {

    public  static List<String> contextId = new ArrayList<String>();

    public static void main(String[] args) throws Exception {
        //getData();
//        for(String link : contextId){
//            System.out.println(link);
//        }
        getSchool();
    }

    public static void getData (){
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File("id.txt")),
                    "UTF-8"));
            String lineTxt = null;
            while ((lineTxt = br.readLine()) != null) {
                contextId.add("https://zhongchou.modian.com/item/"+lineTxt.trim()+".html");
            }
            br.close();
        } catch (Exception e) {
            System.err.println("read errors :" + e);
        }

    }

    public static void sleep58() throws InterruptedException {
        //创建Random类对象
        Random random = new Random();
        //产生随机数
        int number = random.nextInt(10000 -7000 + 1) + 7000;
        sleep(number);
    }

    public static void sleep24() throws InterruptedException {
        //创建Random类对象
        Random random = new Random();
        //产生随机数
        int number = random.nextInt(6000 - 4000 + 1) + 4000;
        sleep(number);
    }


    //爬取全部学院的url
    public static void getSchool() throws Exception {

            String url = "https://app.bilibili.com/x/v2/show/popular/selected?type=weekly_selected&number=";

            try {
                String result = HttpUtils.doGet(url,"53");
                System.out.println(result);

                Gson gson = new Gson();
                Entity entity = gson.fromJson(result, Entity.class);
                System.out.println(entity.getData().getList().get(1).getTitle());


            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }





}
